--
-- Created by IntelliJ IDEA.
-- User: galileoliu
-- Date: 2018/4/16
-- Time: 17:52
-- Copyright (c) 2018      Figure Inc.
--

-- TrackTaskGrayBattleRewardTips

local TrackTaskGrayBattleRewardTips = app.mvc.createPanelClass(...)

function TrackTaskGrayBattleRewardTips.create(node, data)
    local tips = TrackTaskGrayBattleRewardTips.extend(node or cc.CSLoader:createNode(Res.TrackTaskGrayBattleRewardTips))
    tips:init(data)

    return tips
end

function TrackTaskGrayBattleRewardTips:init(data)
    self.super.init(self, data)

    local strTrophyDesc = L("ashes_trophy_description")
    local config = GD:queryEventModeById(Enums.TeamTarget.ashInvade)
    local strCondition = config.condition  -- 1;3;4
    local temp1 = {}
    for w in string.gmatch(strCondition, "%d+") do
        table.insert(temp1, w)
    end
    local strRewardPoint1 = config.reward1 -- 91|0|40
    local strRewardPoint2 = config.reward2 -- 91|0|40
    local strRewardPoint3 = config.reward3 -- 91|0|40
    local temp2 = {}
    for w in string.gmatch(strRewardPoint1, "%d+") do
        table.insert(temp2, w)
    end
    for w in string.gmatch(strRewardPoint2, "%d+") do
        table.insert(temp2, w)
    end
    for w in string.gmatch(strRewardPoint3, "%d+") do
        table.insert(temp2, w)
    end
    local strBronze = string.format(strTrophyDesc, temp1[1], temp2[3])
    local strSilver = string.format(strTrophyDesc, temp1[2], temp2[6])
    local strGold = string.format(strTrophyDesc, temp1[3], temp2[9])
    self._ui["Panel/Panel_Content/Panel_2/userContent_2"]:setString(strGold)
    self._ui["Panel/Panel_Content/Panel_2_0/userContent_2"]:setString(strSilver)
    self._ui["Panel/Panel_Content/Panel_2_1/userContent_2"]:setString(strBronze)

    ccui.Helper:doLayout(self)
end

return TrackTaskGrayBattleRewardTips
